﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class rxt_gpzj_Edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GpzjBLL bll = new GpzjBLL();
            var lst = bll.GetTop50();
            int id = int.Parse(Request["id"]);
            Gpzj c = lst.Single(x => x.Id == id);
            hidId.Value = c.Id.ToString();
            txtTitle.Text = c.Name;
            txtUrl.Text = c.Link;
            txtMrTime.Text = c.MrTime.ToString();
            txtZf.Text = c.UpDown;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Gpzj c = new Gpzj();
        c.Name = txtTitle.Text;
        c.Link = txtUrl.Text;
        c.MrTime = DateTime.Parse(txtMrTime.Text);
        c.UpDown = txtZf.Text;
        c.Id = int.Parse(Request["id"]);
        GpzjBLL bll = new GpzjBLL();
        if (bll.Update(c))
        {
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改成功');document.location='rxtGpzj.aspx'", true);
        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改失败');", true);
        }
    }
}